﻿@model IEnumerable<ElearningOUHv2.Models.Emne>
@{
    ViewBag.Title = "E-Learning Emner";
    Session.Add("help", "Emne/IndexSpg");
}
<h2>
    Vælg et emne for at begynde</h2>
@{string message = ""; }
@{string[] svaretlist = ViewBag.SvaretList; }
@using (Html.BeginForm())
{
    if (svaretlist != null)
    {
    @Html.DropDownList("emner", new SelectList(Model.Select(model => model.emnenavn)), new { onclick = "run()" })
    }
    else
    {
    @Html.DropDownList("emner", new SelectList(Model.Select(model => model.emnenavn)))
    }
    <input value="Vælg" type="submit" />    <div id="SubjectInfo">
    </div>
}
@if (svaretlist != null)
{
    for (int i = 0; i < svaretlist.Count(); i++)
    {
        message += "array[" + i + "]=\"" + svaretlist[i] + "\";\n";
    }
}
<div id="temp">
</div>
@if (svaretlist != null)
{
    <script type="text/javascript">
    var array = new Array();   
@MvcHtmlString.Create(message)
    run();

    function run() {
        var choisen = document.forms[0]["emner"].selectedIndex;
        document.getElementById("SubjectInfo").innerHTML = array[choisen];
           }
    </script>
}
